package com.ysm.smfu.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.squareup.leakcanary.RefWatcher;
import com.umeng.analytics.MobclickAgent;
import com.ysm.smfu.BaseApp;
import com.ysm.smfu.utils.UIUtils;

import chatuidemo.runtimepermissions.PermissionsManager;

/**
 * Created by Administrator on 2016/10/20.
 */
public class MyBaseFragment extends Fragment {
    public void refresh() {
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        PermissionsManager.getInstance().notifyPermissionsChange(permissions, grantResults);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(getActivity().getLocalClassName());
        afterOnResume();
    }

    protected void afterOnResume() {
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(getActivity().getLocalClassName());
        afterOnPause();
    }

    protected void afterOnPause() {
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        RefWatcher refWatcher = ((BaseApp) UIUtils.getContext()).refWatcher;
        if (refWatcher != null)
            refWatcher.watch(this);
    }
}
